﻿@model SelfMadeMillionaire.Web.Infrastructure.ViewModels.Account.ProfileViewModel
@{
	ViewBag.Title = "Profile";
    Layout = "~/Views/Shared/_WideLayout.cshtml";
}

<h4 class="admin_container_ttile">My Profile</h4>

<div class="admin_container_body">

	<div class="personal_contain">
		<ul class="nav nav-tabs" id="myTab">
			<li class='@(Model.SubscriptionTabSelected ? "" : "active")'><a href="#personalInformation" data-toggle="tab">Personal Information</a></li>            
			<li class='@(Model.SubscriptionTabSelected ? "active" : "")'><a href="#subscription" data-toggle="tab">Subscription</a></li>
            <li class=""><a href="#portfolios" data-toggle="tab">Watch Lists</a></li>
		</ul>

		<div class="tab-content">
			<!--personal information-->
			<div class="tab-pane @(Model.SubscriptionTabSelected ? "" : "active")" id="personalInformation">
				@{Html.RenderAction("PersonalInfo");}
		    </div>

	        <!--subscription-->
	        <div class="tab-pane @(Model.SubscriptionTabSelected ? "active" : "")" id="subscription">
		        <!--newsletter subscribe block-->
		        @{Html.RenderAction("SubscriptionInfo");}
	        </div>

            <!--portfolios-->
            <div class="tab-pane" id="portfolios">
		        
	        </div>
        </div>
</div>

</div>

<script type="text/javascript">
    $(document).ready(function () {
        LoadUserPortfolios();
    });

    function CheckAjaxAuthError(result) {
        if ((!result.success) && (result.message == 'session')) {
            window.location = window.location;
        }
    }

    function TestSession() {
        $.ajax({
            url: "@Url.Action("IsAuthorize")",
            cache: false,
            success: function (result) {
                CheckAjaxAuthError(result);
            }
        });
    }

    function LoadUserPortfolios() {
        TestSession();

        var selectedPortfolioId = -1;
        if ($("#SelectedPortfolioId").length) {
            selectedPortfolioId = $("#SelectedPortfolioId").val();
        }
        $.ajax({
            url: "@Url.Action("Portfolios")",
            cache: false,
            data: {
                selectedPortfolioId: selectedPortfolioId
				},
            success: function (result) {
                $("#portfolios").html(result);
            }
        });
    }

</script>